<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends AdminController {
    public function index(){
        //用户总数
        $user_num = M('user')->count();
        //商品总数
        $goods_num = M('goods')->count();
        //销售总数
        $order_num = M('order')->count();
        //秒杀数量
        $seckill_num = M('seckill')->count();
        //团购数量
        $group_num = M('group')->count();

        $num = array(
            'user_num'=>$user_num,
            'goods_num'=>$goods_num,
            'order_num'=>$order_num,
            'seckill_num'=>$seckill_num,
            'group_num'=>$group_num
            );
        $this->assign('num',$num);
        //商品销售列表
        $orderlist = M('orderdetail')
            ->field("g.name,od.price,od.num,od.order_id")
            ->alias('od')
            ->join('shopping_goods g ON od.goods_id= g.id')
            ->limit(5)
            ->select();
        $this->assign('orderlist',$orderlist);
//        状态
        //订单
          //未完成订单
        $order_n = M('order')->where("is_ok=0")->count();
          //已完成订单
        $order_y = M('order')->where("is_ok=1")->count();

        //促销
          //秒杀订单
        $order_gs = M('order')->where("goods_type=1")->count();
        //团购订单

        //售后
          //待退款商品

        //结算
          //待支付
        $order_npay = M('order')->where("is_pay=1")->count();
        //待确定订单
        $order_ypay = M('order')->where("is_pay=1")->count();
    $status_num = array(
        "order_n"=>$order_n,
        "order_y"=>$order_y,
        "order_gs"=>$order_gs,
        "order_npay"=>$order_npay,
        "order_ypay"=>$order_ypay
    );
        $this->assign("status_num",$status_num);
        $this->display('Index/index');
    }
}